package laboesi;



public class TableauxInt {

    public static void initialiser (int [] tab) {

	int i;

	for ( i=0; i<tab.length; i++) {

	    tab[i]=0;
	}
    }
    public static void afficher ( int [] tab) {

	int i;

	for ( i=0; i<tab.length; i++) {

	    System.out.print(tab[i] + ", ");
	}
	System.out.println("");
    }
    public static int []  creer (int taille, int  valInitial){

	int i;
	int [] tab;
	tab = new int[taille];
	for ( i=0; i<taille; i++) {

	    tab[i]=valInitial;

	}
	//afficher(tab);
	return tab;
    }
    public static int somme (int [] tab){

	int somme, i;
	somme = 0;
	for (i=0; i<tab.length; i++) {
	    somme = somme + tab[i];
	}
	return somme;

    }
    public static int max2Nbr ( int nb, int nb2) {
	if (nb>nb2) {
	    return nb;
	}
	else 
	{
	    return nb2;
	}
    }
    public static int maximum (int [] tab) {

	int max, i;
	max = tab[0];

	for ( i=0; i < tab.length; i++) {

	    max = max2Nbr(max,tab[i]); 
	}
	return max;
    }
    public static int indiceMin (int [] tab) {

	// tableau vide ? 
	int indiceMax, nbrMax, i; 
	indiceMax = 0;
	nbrMax = tab[0];
	for ( i=0; i< tab.length; i++) {
	    if ( tab[i] < nbrMax) {
		indiceMax = i;
		nbrMax = tab[i];
	    }

	}
	return indiceMax;

    }
    static int indiceMax (int [] tab) {

	// tableau vide ? 
	int indiceMax, nbrMax, i;
	indiceMax = 0;
	nbrMax = tab[0];
	for ( i=0; i< tab.length; i++) {
	    if ( tab[i] >  nbrMax) {
		indiceMax = i;
		nbrMax =  tab[i];
	    }

	}
	return  indiceMax;

    }

    public static boolean ordonneTab ( int [] tab ) {

	int i; 
	boolean ok;
	ok = true;
	i = 0; 
	while ( i < tab.length-1 && ok  ) {
	    //System.out.print("ok : ");
	    //System.out.print(ok);
	    //System.out.println("");
	    //System.out.print("i: ");
	    //System.out.print(i);
	    //System.out.println("");
	    if (tab[i+1]<tab[i]) {
		ok = false;
	    }
	    i++;

	}
	return ok; 

    }
    public static int [] positionMin ( int [] tab) {

	int [] tabIndice;
	tabIndice = new int [tab.length];

	int i, nbrDeMin, nbMin, nbNext;
	nbrDeMin = 1;
	initialiser(tabIndice);
	nbMin = tab[0];
	tabIndice[0] = 0;
	for ( i =1 ; i < tab.length; i++) {
	    nbNext = tab[i];

	    if ( nbMin > nbNext) {
		nbrDeMin = 0;
		initialiser(tabIndice);
		tabIndice[nbrDeMin] = i;
		nbMin = nbNext;
		nbrDeMin++;

	    }else {

		if ( nbMin == nbNext) {
		    tabIndice[nbrDeMin] = i;
		    nbrDeMin++;	   
		}
	    }
	}
	return tabIndice;
    }
    public static int [] inverser (int [] tab) {

	int i, i2, val;
	i = 0;
	i2 = tab.length - 1 ;
	//	System.out.print("i = ");
	//	System.out.print(i);
	//	System.out.println("");
	//	System.out.print("i2 = ");
	while ( i != i2 && i2 > 0) {

	    
	    //System.out.print(i);
	    //System.out.println("");
	    //System.out.print("i2 : ");
	    //System.out.print(i2);
	    //System.out.println("");
	    val = tab[i];
	    tab[i] = tab[i2];
	    tab[i2] = val;
	    i++;
	    i2--;

	}


	return tab;

    }
    public static int [] positionsMin (int [] tab) {

	int [] tabIndice;
	int i, nbrDeMin, nbMin, nbNext;
	tabIndice = new int [tab.length];
	nbrDeMin = 1;
	initialiser(tabIndice);
	nbMin = tab[0];
	tabIndice[0] = 0;


	for ( i=1 ; i < tab.length; i++){

	    nbNext = tab[i];

	    if ( nbMin > nbNext ) {
		nbrDeMin = 0;
		initialiser(tabIndice);
		tabIndice[nbrDeMin] = i ;
		nbMin = nbNext;
		nbrDeMin++;
	    }else{

		if (nbMin == nbNext) {

		    tabIndice[nbrDeMin] = i;
		    nbrDeMin ++;

		}
	    }

	}

	return tabIndice;


    }



    public static void main ( String[] args ) { 

	

	int [] tabEnt = {2,3,4,5,6,7,8,1,9,10,11,12,13,14,15,16,17} ;

	//int taille, valInitial;
	//taille = clavier.nextInt();
	//valInitial = clavier.nextInt();
	//int n;
	//n = clavier.nextInt();
	//int [] tab;
	//tab = new int[n];
	//System.out.println(tab.length);
	//initialiser(tab);
	//afficher(tab);
	//creer(taille,valInitial);
	afficher(tabEnt);
	//System.out.println(maximum(tabEnt));
	//System.out.println(indiceMax(tabEnt));
	//afficher(positionMin(tabEnt));
	//afficher(positionsMin(tabEnt));
	//afficher(positionMin(tabEnt));
        System.out.println(somme(tabEnt));
    }

}
